package com.xuxin.nantai.presenter;

import com.xuxin.nantai.bean.BaseBean;
import com.xuxin.nantai.bean.ColorBean;
import com.xuxin.nantai.bean.ProductInfoBean;
import com.xuxin.nantai.contract.ChaiUpdateContract;
import com.xuxin.nantai.model.ChaiUpdateModel;

/**
 * Created by xu_xin
 * Created on 2020.06.19 0019
 */
public class ChaiUpdatePresenter implements ChaiUpdateContract.Presenter {
    private ChaiUpdateModel model;
    private ChaiUpdateContract.View view;

    public ChaiUpdatePresenter(ChaiUpdateContract.View view) {
        model = new ChaiUpdateModel();
        this.view = view;
    }

    @Override
    public void getAllProductInfo(String InsType) {
        if (null != model) {
            model.getAllProductInfo(this, InsType);
        }
    }

    @Override
    public void getColor(String cInvName) {
        if (null != model) {
            model.getColor(this, cInvName);
        }
    }

    @Override
    public void update(String LoginName,
                       String UserName,
                       String Guid,
                       String ID,
                       String cInvName,
                       String myColor,
                       String PackQty,
                       String InspectorName,
                       String InspectorCode,
                       String InspectTime,
                       String FacArea,
                       String DefectNum,
                       String DefectDes,
                       String Remark) {
        if (null != model) {
            model.update(this,
                    LoginName,
                    UserName,
                    Guid,
                    ID,
                    cInvName,
                    myColor,
                    PackQty,
                    InspectorName,
                    InspectorCode,
                    InspectTime,
                    FacArea,
                    DefectNum,
                    DefectDes,
                    Remark);
        }
    }

    @Override
    public void onSuccess(ProductInfoBean productInfoBean) {
        if (null != view) {
            view.onSuccess(productInfoBean);
        }
    }

    @Override
    public void onSuccess(ColorBean colorBean) {
        if (null != view) {
            view.onSuccess(colorBean);
        }
    }

    @Override
    public void onSuccess(BaseBean baseBean) {
        if (null != view) {
            view.onSuccess(baseBean);
        }
    }

    /**
     * 以下内容复用
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}